#ifndef MANAGE_H
#define MANAGE_H

#include <QWidget>
#include "Team.h"
#include "Add.h"
#include <QSqlQueryModel>

namespace Ui {
class Manage;
}

class Server;  // 前向声明

class Manage : public QWidget
{
    Q_OBJECT

public:
    explicit Manage(Server *server,QWidget *parent = nullptr);
    ~Manage();
    void refreshPageData();

protected:
    // 用于拖动窗口的事件处理函数
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;

    void paintEvent(QPaintEvent *event) override;

private slots:
    void on_returnButton_clicked();

    void on_set_clicked();

    void on_add_clicked();

    void on_man_clicked(const QModelIndex &index);
    void on_group_clicked(const QModelIndex &index);

private:
    Ui::Manage *ui;
    Server *serverWindow;
    QStringListModel *employeeModel;
    QStringListModel *groupModel;
    void loadEmployeeInfo();
    void loadGroupInfo();
    QSqlDatabase db;

    // 用于记录拖动时鼠标位置的成员变量
    QPoint m_dragPosition;

    // 添加用于判断是否点击标题栏的成员变量
    bool m_isTitleBarClicked = false;
};

#endif // MANAGE_H
